<!DOCTYPE html>
<html>

	<head lang="en">
		<title>找攻略</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
		<script src="/js/plugins/jquery/jquery.min.js"></script>
		<script src="/js/plugins/form/jquery.form.js"></script>
		<script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="/css/font/css/font-awesome.min.css" />
		<link rel="stylesheet" href="/css/reset.css" />
		<link rel="stylesheet" href="/css/myStrategyComment.css" />
		<script src="/js/plugins/jrender/jrender.min.js"></script>
		<link rel="stylesheet" href="/js/plugins/jquery-confirm/css/jquery-confirm.css">
		<script src="/js/plugins/jquery-confirm/js/jquery-confirm.js"></script>
		<script src="/js/common.js"></script>
		<script>
			$(function () {
				var user = JSON.parse(sessionStorage.getItem('user'));
				var params = getParams();
			    //点击提交点评
                $('#submitBtn').click(function () {
                    //点评内容
					var content = $('textarea[name="content"]').val();
                    console.log(content);
                    //点评的游记id
                    var travelId = params.id;
                    //点评人的id
                    var userId = user.id;
                    console.log(imgUrls);
                    //提交给后台
                    $.post('/travelComments/save',{
						content:content,
						imgUrls:imgUrls,
                        'user.id':userId,
                        travel_id:travelId,
						state:0
                    },function (data) {
                        location.href="/index.html";
                    });
                });

                //点评图片
                var imgUrls = "";


                //触发查看图片文件
				$('.rect').click(function () {
					$("#file").click();
                });
                $("#file").change(function () {
                    if ($(this).val()) {
                        $("#imgForm").ajaxSubmit(function (data) {
                            if (data.status == 1) {
                                $('.picture').prepend('<div class="col-3 rect">\n' +
                                    '\t\t\t\t\t<img src="'+data.url+'">\n' +
                                    '\t\t\t\t</div>');
                                imgUrls = imgUrls + data.url +";";
                            }
                        });
                    }
                });
            })
		</script>

	</head>

	<body>
	<div class="search-head">
		<div class="row nav-search">
			<div class="col">
				<a href="javascript:window.history.go(-1)">
					<span><i class="fa fa-chevron-left" ></i></span>
				</a>
			</div>
			<div class="col">
				<span>点评</span>
			</div>
			<div class="col"></div>
		</div>
	</div>

	<div class="comment">
		<hr />
		<div class="container tag">
			<p>游记评价内容</p>
			<textarea name="content" class="form-control" rows="5" placeholder="请填写你对该游记的评价"></textarea>
		</div>
		<div class="container imgs ">
			<p>上传图片</p>
			<div class="row picture">
				<form id="imgForm" action="/images" method="post" enctype="multipart/form-data">
					<input type="file" style="display: none" name="file" id="file"/>
				</form>
				<div class="col-3 rect">
					<span>上传</span>
				</div>
			</div>
		</div>

	</div>



	<div class="operation">
		<button class="btn" onclick="window.history.go(-1)">放弃评价</button>
		<button class="btn" id="submitBtn">提交评价</button>
	</div>





	</body>


</html>